package com.railway.bean;

import java.util.Date;
import java.util.List;

/**用户积分类
 * @author 33676
 *
 */
public class Integra {

	private int integra_id;	//积分id
		
	private int countImtegral = 0 ;//积分总数
	
	private List<IntegraDetailed > integraDetaileds ;//积分详细
	
	private int Number_of_credits_aboutTo_expire = 0 ;//即将过期积分数


	public int getIntegra_id() {
		return integra_id;
	}

	public void setIntegra_id(int integra_id) {
		this.integra_id = integra_id;
	}

	public int getCountImtegral() {
		return countImtegral;
	}

	public void setCountImtegral(int countImtegral) {
		this.countImtegral = countImtegral;
	}



	public void setIntegraDetaileds(List<IntegraDetailed> integraDetaileds) {
		this.integraDetaileds = integraDetaileds;
		for (IntegraDetailed integraDetailed : this.integraDetaileds) {
			if((new Date()).getTime()-integraDetailed.getCreate_at().getTime() <12*30*24*60*60*1000) {
				if("-".equals(integraDetailed.getGive_or_take())) {
					countImtegral -= integraDetailed.getIntegral_num();
				}else if("+".equals(integraDetailed.getGive_or_take())) {
					countImtegral += integraDetailed.getIntegral_num();
				}
			}
			
			if((new Date()).getTime()-integraDetailed.getCreate_at().getTime() >10*30*24*60*60*1000 &&
					(new Date()).getTime()-integraDetailed.getCreate_at().getTime() <12*30*24*60*60*1000
				) {
				if("+".equals(integraDetailed.getGive_or_take())) {
					Number_of_credits_aboutTo_expire += integraDetailed.getIntegral_num();
				}
			}
		}
	}
	
	public int getIncrease_or_decrease() {
		return Number_of_credits_aboutTo_expire;
	}

	public Integra() {
		super();
		// TODO Auto-generated constructor stub
	}	

}
